Webp is a popular image format that is highly optimized for delivery on websites and web applications. Since it is much smaller in size than traditional image files such as PNG, JPG & Gifs they can be loaded faster, and consume less data. But sometimes you may need to convert webp to gif in Linux. You can easily do this using ImageMagick library. In this article, we will learn how to convert webp to gif in Linux.
How to Convert Webp to Gif in LinuxHere are the steps to convert webp to gif in Linux. Here are the steps to install ImageMagick.
1. Install ImageMagick$ sudo apt update$ sudo apt install imagemagickAlternatively, you can compile ImageMagick from source. Download ImageMagick tar.gz file from here.
Extract the tarball you have downloaded.
$ tar -xvf ImageMagick.tar.gz$ cd ImageMagick-7.0.10-11/Run the following command to compile ImageMagick.
$ ./configure$ makeRun the following command to install ImageMagick.
$ sudo make installRun the following command to configure dynamic run-time bindings.
$ sudo ldconfig /usr/local/lib2. Convert Webp to GifImageMagick package consists of several image editing tools. Out of them, you can use convert and mogrify command to convert webp to gif files. Let us say you have test.webp image. Here is the command to convert test.webp image to test.gif. Here is the syntax of convert command.
$ convert [options] /path/to/webp /path/to/gifIn the above command, you need to specify the source path to web image first, followed by target path to gif image.
Here is an example to convert /home/ubuntu/test.webp to /home/ubuntu/test.gif.
$ sudo convert /home/ubuntu/test.webp /home/ubuntu/test.gifThe above command convert can only convert one file at a time. If you want to convert more than one webp images to gif, then you need to use mogrify command. Here is the syntax to convert .webp images to gif files using mogrify command.
$ mogrify [options] /path/to/source/fileHere is the command to convert all .webp images in /home/ubuntu folder to gif files.
$ sudo mogrify -format gif /home/ubuntu/*.webpWith mogrify command, if you mention only the source path of webp files it will replace them with converted gif files.
If you don’t want to overwrite the existing files but create the converted files at a different location, then specify the destination path using -path option.
$ mogrify -format pdf -path /home/ubuntu /home/ubuntu/*.jpgIf the above mogrify command doesn’t work for you, then depending on the platform and type of ImageMagick installation, you may need to add keyword magick before your mogrify command.
$ magick mogrify -format pdf /home/ubuntu/*.jpg$ magick mogrify -format pdf -path /home/ubuntu /home/ubuntu/*.jpgIn this article, we have learnt how to convert webp to gif images in Linux. You can run them as standalone commands or as a part of a bigger shell script in Linux. If you want to convert single webp file to gif, you can use convert or mogrify commands. If you want to convert multiple webp images to gif files, you need to use mogrify, or call convert command while running a loop through your webp files.
Also read:
How to Convert Images to Webp in LinuxHow to Convert Images to Webp in PythonHow to Check If User Has Sudo AccessHow to Combine JSON Files to CSV FilesHow to Convert JSON to CSV in Python
Related posts:How to Block USB Storage Devices in LinuxHow to Convert Home Directory Into Partition in LinuxHow to Search a File in LinuxHow to Reconfigure Installed Package in Ubuntu/Debian LinuxHow to Find Hardware Details in UbuntuHow to Install CSF in CentOS & UbuntuHow to Remove PPA in Ubuntu/Debian LinuxHow To Use rsync Command in LinuxSreeram SreenivasanSreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.